﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NewStart
{
    public partial class AppMenuItem : UserControl
    {
        public string path;

        public string name
        {
            get { return label1.Text; }
        }

        public AppMenuItem(string path, string name)
        {
            InitializeComponent();
            label1.Text = name;
            this.path = path;
            pictureBox1.Image = ShortcutsHelper.GetIcon(path);
        }

        private void pinToStartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TilesHelper.AddTile(this.name, this.path);
        }

        private void label1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(this.PointToScreen(Point.Empty));
            }
            else
            {
                System.Diagnostics.Process.Start(path);
                ((AppForm)this.ParentForm).DialogResult = DialogResult.OK;
                ((AppForm)this.ParentForm).Close();
                ((AppForm)this.ParentForm).textBox1.Text = "";
            }
        }
    }
}
